﻿using System.Web.UI;

namespace TheOutfield.UmbExt.PageNotifications.Util
{
    public static class ControlUtil
    {
        internal static Control FindControlRecursive(Control rootControl, string controlToFindId)
        {
            if (rootControl == null)
                return rootControl;
            
            if (rootControl.ID == controlToFindId)
                return rootControl;
            
            foreach (Control control in rootControl.Controls)
            {
                Control control2 = FindControlRecursive(control, controlToFindId);
                if (control2 != null)
                    return control2;
            }
            return null;
        }
    }
}